package data;

import model.FootBallMember;
import model.MostFooterEnum;
import model.Position;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class FootBallMemberConstants {

    public  static List<FootBallMember> footBallMembers = new ArrayList<FootBallMember>();

    public static  List<FootBallMember> getFootBallMembers(){
        if (footBallMembers.size() == 0){

            //初始化一定量数据
            for (int i = 0 ; i <150; i ++){
                //年龄
                int age = (int)(Math.random()*19+16);

                Random random = new Random();
                //惯用脚
                MostFooterEnum mostFooterEnum = null;
                int mostFooterInt = random.nextInt(2);
                for (MostFooterEnum footerEnum : MostFooterEnum.values()){
                    if (footerEnum.IntValule() == mostFooterInt ){
                            mostFooterEnum = footerEnum;
                    }
                }

                //场上位置
                Position position = null;
                int posistionInt = random.nextInt(4);
                for (Position position1 : Position.values()){
                    if (position1.IntValule() == posistionInt){
                        position = position1;
                    }
                }

                //薪水
                BigDecimal salary = new BigDecimal(age-SalaryBase.BASE_AGE).
                        multiply(new BigDecimal(SalaryBase.BASE_STEP)).
                        multiply(SalaryBase.START_SALARY);
                //球队
                int clubId = random.nextInt(FootBallClubConstants.getALlFootBallData().size());
                String clubName = FootBallClubConstants.getALlFootBallData().get(clubId);
                //姓名
                String name = "Wangdalei"+i ;
               
                //身高
                String height = (int)(Math.random()*40 + 165)+"";
                //能力值
                int ability = random.nextInt(200);
                //国家队
                int isNation = random.nextInt(2);
                boolean isNationBo = true;
                if (isNation == 1){
                    isNationBo = false;
                }
                if (isNationBo && ability > 90){
                    isNationBo = true;
                }
                else {
                    isNationBo = false;
                }
                FootBallMember member = new FootBallMember(age,mostFooterEnum,position,salary,clubName,name,height,ability,isNationBo);
                member.setCanTitile();
                footBallMembers.add(member);

            }
            return footBallMembers;
        }else {
            return footBallMembers;
        }
    }

    public static void setFootBallMembers(List<FootBallMember> footBallMembers) {
        FootBallMemberConstants.footBallMembers = footBallMembers;
    }
}
